package com.jbm.jbmsupplier.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jbm.jbmsupplier.R;
import com.jbm.onehome.iface.IOrder;

import java.util.ArrayList;

/**
 * Created by 家帮忙 on 2017/4/11.
 */

public class IncomeAdapter extends BaseAdapter {
    private Context context;
    ArrayList<IOrder> listadate;

    public IncomeAdapter(Context context, ArrayList<IOrder> listadate) {
        this.context = context;
        this.listadate = listadate;
    }

    @Override
    public int getCount() {
        return listadate.size();
    }

    @Override
    public Object getItem(int position) {
        return listadate.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Viewholder viewholder;
        if (convertView==null){
             convertView=View.inflate(context, R.layout.pledge_lz,null);
            viewholder=new Viewholder(convertView);
            convertView.setTag(viewholder);
        }else{
            viewholder= (Viewholder)convertView.getTag();
        }
        IOrder polis = listadate.get(position);
        initviewdate(viewholder,polis,position);

        return convertView;
    }

    private void initviewdate(Viewholder viewho, IOrder polis, int po) {
        viewho.texuhao.setText(po+"");
        viewho.tejines.setText(polis.amount+"");
        viewho.texbianh.setText(polis.caddr_id+"");
        viewho.texriqi.setText(polis.create_date);
    }

    class Viewholder{
        TextView texuhao,tejines,texbianh,texriqi;
        public Viewholder(View conver) {
            texuhao=(TextView) conver.findViewById(R.id.texuhao);
            tejines=(TextView) conver.findViewById(R.id.tejines);
            texbianh=(TextView) conver.findViewById(R.id.texbianh);
            texriqi=(TextView) conver.findViewById(R.id.texriqi);

        }
    }



}
